package velox.docdb.backend.jcr;

import javax.jcr.Node;

import org.springmodules.jcr.JcrTemplate;

import velox.docdb.Document;
import velox.docdb.Session;

public class JcrSession implements Session {

	private JcrTemplate template;
	
	public Document getDocumentByPath(String path) {
		String jcrPath = convertPath(path);
		return createJcrDocument((Node) template.getItem(jcrPath));
	}

	public Document getDocumentByUUID(String uuid) {
		return createJcrDocument((Node) template.getNodeByUUID(uuid));
	}

	public Document getRootDocument() {
		return createJcrDocument(template.getRootNode());
	}	

	public void save() {
		
	}

	
	private String convertPath(String path) {
		// /documents/kalle/types/type1
		return "/docs/documents/kalle/docs/types/type1";
	}
	
	private Document createJcrDocument(Node item) {
		// TODO Auto-generated method stub
		return null;
	}
}
